package com.isoft.controller;
import com.isoft.common.Result;
import com.isoft.entity.FixRecord;
import com.isoft.mapper.FixRecordMapper;
import com.isoft.service.FixRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class FixRecordController {
    @Autowired
    private FixRecordService fixRecordService;

    @PostMapping("/FixRecord")
    public Result<?> fixrecord(@RequestBody FixRecord fixRecord){
        fixRecordService.userFixRecord(fixRecord);
        return Result.success();
    }

    @GetMapping("/queryFixRecords")
    public Result<List<FixRecord>> queryFixRecords(
            @RequestParam(value = "startDate", required = false) String startDate,
            @RequestParam(value = "endDate", required = false) String endDate) {
        List<FixRecord> fixRecords = fixRecordService.queryFixRecords(startDate, endDate);
        if (fixRecords != null) {
            return Result.success(fixRecords);
        } else {
            return Result.error("1", "没有查询到相关日志");
        }
    }


}
